package com.原型模式;

/**
 * @author Fang Ruichuan
 * @date 2022-09-22 9:31
 */

public class Client {
    public static void main(String[] args) {
        System.out.println("原型模式完成对象的创建");
        Sheep sheep = new Sheep("Tom", 1, "白色");
        sheep.friend = new Sheep("jack", 2, "黑色");
        Sheep sheep2 = (Sheep) sheep.clone();
        Sheep sheep3 = (Sheep) sheep.clone();
        Sheep sheep4 = (Sheep) sheep.clone();
        System.out.println("sheep2: " + sheep2 + "sheep.friend2: " + sheep2.friend.hashCode());
        System.out.println("sheep3: " + sheep3 + "sheep.friend3: " + sheep3.friend.hashCode());
        System.out.println("sheep4: " + sheep4 + "sheep.friend4: " + sheep4.friend.hashCode());
    }
}
